// components/musiclist/musiclist.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list: Array
  },

  /**
   * 组件的初始数据
   */
  data: {
    playingMusicId: -1 // 当前播放的歌曲索引
  },

  pageLifetimes: {
    show() {
      this.getPlayingMusicId();
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    getPlayingMusicId() {
      this.setData({
        playingMusicId: parseInt(app.getPlayMusicId())
      });
      // console.log(this.data.playingMusicId);
    },
    // 跳转
    goPlay(e) {
      // console.log(e);
      const id = e.currentTarget.dataset.id,
        index = e.currentTarget.dataset.index;
      wx.navigateTo({
        url: `/pages/player/player?musicId=${id}&index=${index}`,
      })
    }
  }
})
